///*
// * To change this template, choose Tools | Templates
// * and open the template in the editor.
// */
//package ru.ipccenter.war;
//
//import java.io.IOException;
//import java.io.StringWriter;
//import java.util.HashMap;
//import java.util.Iterator;
//import java.util.Map;
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.naming.*;
//import javax.xml.parsers.DocumentBuilder;
//import javax.xml.parsers.DocumentBuilderFactory;
//import javax.xml.parsers.ParserConfigurationException;
//import javax.xml.transform.Transformer;
//import javax.xml.transform.TransformerConfigurationException;
//import javax.xml.transform.TransformerException;
//import javax.xml.transform.TransformerFactory;
//import javax.xml.transform.dom.DOMSource;
//import javax.xml.transform.stream.StreamResult;
//import org.w3c.dom.Document;
//import org.w3c.dom.Element;
//import ru.ipccenter.ejb.*;
//import ru.ipccenter.ejb.UserInterface.Result;
//import ru.ipccenter.war.Check.Result;
//
///**
// *
// * @author nick
// */
//public class RegisterCheck extends HttpServlet {
//
//    private UserInterface us = null;
//    private Map<String, UserInterface.Result> res = null;
//    static boolean result = false;
//
//    /**
//     * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
//     * @param request servlet request
//     * @param response servlet response
//     * @throws ServletException if a servlet-specific error occurs
//     * @throws IOException if an I/O error occurs
//     */
//    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
//            throws ServletException, IOException {
//        System.out.println("I am Register Servlet");
//        try {
//            InitialContext ic = new InitialContext();
//            us = (UserInterface) ic.lookup("UserSession");
//
//        } catch (Exception ex) {
//            System.out.println("Error:"
//                    + ex.getMessage());
//        }
//        try {
//            result = false;
//            res = new HashMap<String, UserInterface.Result>();
//
//
//        } catch (Exception ex) {
//            System.out.println("Error:"
//                    + ex.getMessage());
//        }
//    }
//    public boolean result() {
//            int success = 0;
//            for (Iterator<String> I = res.keySet().iterator(); I.hasNext();) {
//                String item = (String)I.next();
//                System.out.println(item);
//                Result itemValue = res.get(item);
//                System.out.println(itemValue);
//                if(itemValue != Result.SUCCESS) {
//                    success += 1;
//                }
//            }
//            if(success == 0) {
//                return true;
//            } else {
//                return false;
//            }
//    }
//    public String toXML() throws ParserConfigurationException, TransformerConfigurationException, TransformerException {
//        String xml = null;
//        DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
//        DocumentBuilder bd = fact.newDocumentBuilder();
//        Document doc = bd.newDocument();
//        Element root = doc.createElement("user");
//        doc.appendChild(root);
//
//        Element temp;
//        for (Iterator<String> I = res.keySet().iterator(); I.hasNext();) {
//            String item = (String)I.next();
//            String itemValue = res.get(item).toString();
//            temp = doc.createElement(item);
//            temp.appendChild(doc.createTextNode(itemValue));
//            root.appendChild(temp);
//        }
//        DOMSource domSource = new DOMSource(doc);
//        TransformerFactory tf = TransformerFactory.newInstance();
//        Transformer transformer = tf.newTransformer();
//
//        StringWriter sw = new StringWriter();
//        StreamResult sr = new StreamResult(sw);
//        transformer.transform(domSource, sr);
//        xml = sw.toString();
//        return xml;
//    }
//
//    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
//    /**
//     * Handles the HTTP <code>GET</code> method.
//     * @param request servlet request
//     * @param response servlet response
//     * @throws ServletException if a servlet-specific error occurs
//     * @throws IOException if an I/O error occurs
//     */
//    @Override
//    protected void doGet(HttpServletRequest request, HttpServletResponse response)
//            throws ServletException, IOException {
//        processRequest(request, response);
//
//
//
//
//    }
//
//    /**
//     * Handles the HTTP <code>POST</code> method.
//     * @param request servlet request
//     * @param response servlet response
//     * @throws ServletException if a servlet-specific error occurs
//     * @throws IOException if an I/O error occurs
//     */
//    @Override
//    protected void doPost(HttpServletRequest request, HttpServletResponse response)
//            throws ServletException, IOException {
//        processRequest(request, response);
//
//
//
//
//    }
//
//    /**
//     * Returns a short description of the servlet.
//     * @return a String containing servlet description
//     */
//    @Override
//    public String getServletInfo() {
//        return "Short description";
//
//
//    }// </editor-fold>
//}
